
#ifndef _MYMATH_H
#define _MYMATH_H

#include <stdlib.h>
//#include "dat_types.h" 
#include "Dl645_Types.h"
#include "gd32f4xx.h"

extern unsigned char fnBcdToHex_u8(unsigned char Dat);
extern unsigned char  BCDtoHEX_u8(unsigned char BCDData);
extern unsigned short  BCDtoHEX_u16(unsigned short BCDData);
extern unsigned long BCDtoHEX_u32(unsigned long BCDData);
extern unsigned char HexToBcd_u8(unsigned char Dat);
extern unsigned short HexToBcd_u16(unsigned short Dat);
extern unsigned long	HexToBcd_u32(unsigned long Dat);
extern unsigned long fnBcdAdd_u32(unsigned long Augend,unsigned long Addend);
extern unsigned long fnBcdSub_u32(unsigned long Reduced ,unsigned long Minuend);
//extern void HEXU32toBCDBuf(unsigned long DecAddr,unsigned char *BcdAddr,unsigned char BcdByteLen);
extern unsigned char GetAccumlation( unsigned char * P_buffer, unsigned short datasize );
extern unsigned short fnCRC16 (unsigned char * Pbuf,unsigned short  usDataLen );
extern unsigned char fnCrc_Check(unsigned char byDir , unsigned char *pStartPos, unsigned short nCheckLen , unsigned char *Crc16);
extern ErrStatus fnDl645B_ByteCheckBCD( u8 Value );
extern unsigned char fnWeek_Calculate(unsigned char Year , unsigned char Month , unsigned char Day);
//extern ErrStatus fnDl645B_FramCheckBCD( u8 *Buf, u8 Len );
extern unsigned char tryfcs16(unsigned char byDir, register unsigned char *cp, register int len);
extern sDF09	fnDFConver_Hex32ToDF09(u32 Dat);
extern sDF25 fnDFConver_Bcd32ToDF25(u32 Dat);
extern u16 fnDFConver_Bcd16To16(s16 Dat);
extern u32 fnDFConver_Bcd32To32(s32 Dat);
//extern unsigned char fnHexToBcd_u8(unsigned char Dat);
ErrStatus checkBCD( unsigned char *Pbuf, unsigned char Len );
ErrStatus ByteCheckBCD( unsigned char Value );
void Ramcpy(unsigned char *pbuf1,unsigned char *pbuf2,unsigned long Len);
unsigned char Ramcmp(unsigned char *pbuf1,unsigned char *pbuf2,unsigned long Len);
void Ramset(unsigned char *pbuf1,unsigned char Data,unsigned long Len);
#endif 





















